<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-L-admin1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="../../css/list-style.css"/>
	<link rel="stylesheet" type="text/css" href="../../css/nav1.css">
    <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/xadmin.css">
    <script src="../../js/jquery.min.js"></script>
    <script type="text/javascript" src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
	<script src="../../js/jquery.min.js"></script>
	<script src="../../js/nav1.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body class=" layui-fluid"><fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  <legend>登陆历史记录</legend>
</fieldset>
<div class="box">
    <div class="myTable">
        <table class="layui-table">
            <thead>
            <tr>
                <th>登录时间</th>
                <th>登录IP地址</th>
            </tr>
            </thead>
            <tbody id="logintr" style="align-content: center;">
           
            </tbody>
        </table>
    </div>
</div>
               <div class="page">
                 <div id="page">

                 </div>
               </div>
          
<script src="../lib/layui/layui.js"></script>
</body>
<script>
	index(1);
	function index(pagenum)
	{
		data={
				"pageNum":pagenum
		}
		$.ajax({
		  	url: "http://www.longm.top:8080/lm/getAdminLoginHistory",
		  	type: "post",
		  	dataType: 'json',
		  	headers:{'Content-Type':'application/json',
					'token':window.localStorage.getItem("token")
					},
		  	data:JSON.stringify(data),
		  	success: function (result) {
		  		console.log(JSON.stringify(result));
		  		if (result.code === 200) {
		  				var data=result.data;
		  				var tbady=document.querySelector("#logintr");
						var page=document.querySelector("#page");
						tbady.innerHTML=null;
		  				for(i=0;i<data.list.length;i++)
		  				{
							var date=new Date(data.list[i].logindate);
		  					var html=
							'<tr><td class="card_id">'+dateFormat("YYYY-mm-dd HH:MM", date)+'</td>'+
							'<td class="deal_money">'+data.list[i].loginip+'</td></tr>';
							tbady.innerHTML=tbady.innerHTML+html;
		  				}
						page.innerHTML=page.innerHTML+'<a class="prev" href="">&lt;&lt;</a>';
						for(a=0;a<data.pages;a++)
						{
							var pagelist='<a class="num">'+(a+1)+'</a>';
							if(a+1==data.pagenum)
							{
								pagelist='<span class="current" onclick="index('+(a+1)+')">'+(a+1)+'</span>'
							}
							page.innerHTML=page.innerHTML+pagelist;
						}
						page.innerHTML=page.innerHTML+'<a class="next" href="">&gt;&gt;</a>';
		  		} else {
		  			layer.msg(result["message"]);
		  		}
		  	}
		  });
	};
	function dateFormat(fmt, date) {
	    let ret;
	    const opt = {
	        "Y+": date.getFullYear().toString(),        // 年
	        "m+": (date.getMonth() + 1).toString(),     // 月
	        "d+": date.getDate().toString(),            // 日
	        "H+": date.getHours().toString(),           // 时
	        "M+": date.getMinutes().toString(),         // 分
	        "S+": date.getSeconds().toString()          // 秒
	        // 有其他格式化字符需求可以继续添加，必须转化成字符串
	    };
	    for (let k in opt) {
	        ret = new RegExp("(" + k + ")").exec(fmt);
	        if (ret) {
	            fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
	        };
	    };
	    return fmt;
	};
	
</script>

</html>